package com.yimiyisu.kooteam;

import com.yimiyisu.kooteam.server.DefaultHttpBootstrap;
import com.yimiyisu.kooteam.server.DefaultHttpServerHandler;
import com.yimiyisu.kooteam.utils.FileUri;
import com.zen.h.a;
import com.zen.kit.PatternKit;


public class ApplicationMain {

    public void registerBean(String name, Object target) {
        try {
            a.a().a(name, target);
        } catch (Exception var4) {
            var4.printStackTrace();
        }
    }

    public void start(String[] args, String appName, Integer port) {
        if (appName != null) {
            com.zen.e.a.a();
            com.zen.d.a.e(appName);
        }

        String[] var4 = args;
        int var5 = args.length;

        for(int var6 = 0; var6 < var5; ++var6) {
            String var7 = var4[var6];
            if (var7.startsWith("-c")) {
                com.zen.d.a.b(false);
            } else if (var7.startsWith("-p")) {
                String var8 = var7.substring(2);
                if (PatternKit.isNumber(var8)) {
                    port = Integer.parseInt(var8);
                }
            }
        }

        Class<?> var9 = this.getClass();
        DefaultHttpBootstrap httpBootstrap = new DefaultHttpBootstrap(var9.getPackage().getName(), port);
        httpBootstrap.configuration()
                .debug(true)
                .serverName(appName)
                .bannerEnabled(false)
                .readBufferSize(1048576)
                .setHttpServerHandler(new DefaultHttpServerHandler());
        ClassLoader classLoader = var9.getClassLoader();
        FileUri.a(classLoader);
        httpBootstrap.setPort(port).start();
    }

    public static void main(String[] args) {
        // org.stone.beecp.BeeDataSource.getConnection()" because "com.zen.c.a.b" is null
        com.zen.d.a.a("dbHost","jdbc:mysql://127.0.0.1/kooteam_test?useUnicode=true&characterEncoding=UTF-8");
        com.zen.d.a.a("dbUser","root");
        com.zen.d.a.a("dbPasswd","root123456");
        com.zen.d.a.a("dbPools","4");

//        com.zen.d.a.a("zenDbHost","127.0.0.1");
//        com.zen.d.a.a("zenDbUser","root");
//        com.zen.d.a.a("zenDbPasswd","root123456");

        // 应用端口
        int listenPort = 7053;
        String appName = "kooteam";
        ApplicationMain app = new ApplicationMain();
        app.scanController();
        app.start(args, appName, listenPort);
    }

    public void scanController() {

    }
}
